home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / WishLs15.cpt / WishCode / WishList.c next >
Text File  |  1992-01-10  |  5KB  |  162 lines

  1. /*
  2.  *   Wish List Module - Version 1.5 - By Scott Szretter
  3.  *
  4.  *      (C)1991 Scott Szretter - Please see the file "COPYRITE.SPS"
  5.  *
  6.  *        ))) Version Changes (((
  7.  * --Version-------------Notes-----------------------------------------------------------------
  8.  *  1.0 -> 1.1 ...   List was not being built properly-fixed & other small code cleanups...
  9.  *  1.1 -> 1.2 ...   Added some features (sysop display, help,Intro,date) & cleanup...
  10.  *  1.2 -> 1.3 ...   Fixed bug with wish being added to INTRO file........
  11.  *  1.3 -> 1.4 ...   Added better err reporting, Better user interface, fixed POSSIBLE bug.
  12.  *  1.4 -> 1.5 ...   Added level/alt wishlist stuff...
  13.  *
  14.  *  This program may not be sold for profit!
  15.  *  The source code is being release for educational purposes only.
  16.  *  I take no responsibility for any damage resulting from this code.
  17.  */
  18. #define INMAIN
  19. #include     <SetUpA4.h>
  20. #include    "MUBBS Module.h"
  21. pascal void main (mode1,G1,P1)
  22.        int mode1;
  23.        struct GS *G1;
  24.        Ptr *P1;{
  25. Handle temph;
  26. float version = 0.5; /* version of MUBBS */
  27. RememberA0(); SetUpA4(); 
  28. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* lock our module. */
  29. G=G1; 
  30. mode[u]=mode1;
  31.  
  32. switch (mode[u]) {
  33.     case 2:
  34.         Wish();
  35.         G->moduleresult=0;
  36.         break;
  37.     case 98:
  38.         versionck(version);
  39.         break;        
  40.     case 0:
  41.         strcpy (G->programmer,"Scott Szretter");
  42.         G->moduleresult=0;
  43.         break;
  44.     default:
  45.         G->moduleresult=1;
  46.         break;};
  47. HUnlock(temph); /* unlock module.*/
  48. RestoreA4();}
  49.  
  50. /****        *   *    *    -Wish-   *   *   *   *          ****/
  51. Wish()  {
  52. FILE *stream;
  53. char filename[65];
  54. char temp[43];
  55. char datetime[25];
  56. char stemp[255];
  57. int SMenu,W,itemp;
  58. if (!G->online[u]) return; /* Log out if hang up */
  59. SMenu=TRUE;
  60. W=TRUE;
  61. strcpy(filename,":wish:");
  62. strcat(filename,G->modulename[u]);
  63. strcat(filename,".intro");
  64. print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
  65. loguser(G->modulename[u]); /* write to log file */
  66. send (G->CR[u]);
  67. sendtext(filename);
  68. while (W=TRUE) {
  69.     if (!G->online[u]) return;
  70.      if (SMenu=TRUE){
  71.         send("]]  *** WishList Menu ***      ");
  72.         send (G->CR[u]);
  73.         if (!(cmd1(">> Display, Add, Help, Quit, Logoff "))) G->online[u]=FALSE;
  74.         SMenu=FALSE;  }
  75.         send(G->CR[u]);
  76.             if (G->input[u] =='Q') {
  77.                 W=FALSE;
  78.                 print("C> Exiting Wishlist -> ",G->username[u]);
  79.                 send("] Thank You for using WishList!");
  80.                 return;}
  81.             if (G->input[u] =='L') {
  82.                 W=FALSE;
  83.                 G->online[u]=FALSE;}
  84.             if (G->input[u] =='H') {
  85.                 strcpy(filename,":wish:");
  86.                 strcat(filename,G->modulename[u]);
  87.                 strcat(filename,".help");
  88.                 send (G->CR[u]);
  89.                 sendtext(filename);
  90.                 send ("]WishList 1.5 By - Scott Szretter");
  91.                 SMenu=TRUE;
  92.                 W=TRUE;}
  93.             if (G->input[u] =='D'){
  94.                     if(G->userpriv[u] > 4) {
  95.                         send("]Display the Alternate wish list ");
  96.                         if (!(cmd1("Y/N?"))) G->online[u]=FALSE;
  97.                         send(G->CR[u]);
  98.                         if (G->input[u] =='Y') {
  99.                         strcpy(filename,":wish:");
  100.                         strcat(filename,G->modulename[u]);
  101.                         strcat(filename,".alt");
  102.                         send (G->CR[u]);
  103.                         sendtext(filename);}}  /* UserPriv & Y to send */
  104.                         if (G->input[u] =='N') {
  105.                             strcpy(filename,":wish:");
  106.                             strcat(filename,G->modulename[u]);
  107.                             strcat(filename,".info");
  108.                             send (G->CR[u]);
  109.                             sendtext(filename);}} /* D!*/
  110.             if (G->input[u] =='A'){
  111.                 if(G->userpriv[u] > 4) {
  112.                     send("]Display the Alternate wish list ");
  113.                     if (!(cmd1("Y/N?"))) G->online[u]=FALSE;
  114.                     send(G->CR[u]);
  115.                     if (G->input[u] =='Y') {
  116.                         send("Please enter your wish (40 characters maximum)");
  117.                         send("] !--------!---------!---------!---------!");
  118.                         send("]>");
  119.                         portsin(temp, 41);
  120.                         send(G->CR[u]);
  121.                         if (temp[0] == 0){
  122.                             send("]Aborted...");
  123.                             send(G->CR[u]);
  124.                             return;} /* temp=0 */
  125.                         strcpy(filename,":wish:");
  126.                         strcat(filename,G->modulename[u]);
  127.                         strcat(filename,".alt");
  128.                         if ((stream = fopen(filename, "a")) == NULL) { /* Open the file */
  129.                             send("]FILE ERROR cannot open %s ]", filename);
  130.                             print("\nFile ERROR Cannot Open %s W",filename);
  131.                                return;} /* stream */
  132.                            gettime("%m/%d/%y",datetime); /* gets the date in m/d/y */
  133.                         if (fprintf(stream,"%-41s %-9s %-29s\r",temp,datetime,G->username[u])==EOF) print("bad fprintf conversion\n");
  134.                         fclose(stream); 
  135.                         send(G->CR[u]);
  136.                         send("Your wish has been added to the WishList!");
  137.                         print("C> Added to ALTERNATE WishList -> ",G->username[u]);}}  /* UserPriv & Y */
  138.                     if (G->input[u] =='N') {
  139.                 send("Please enter your wish (40 characters maximum)");
  140.                 send("] !--------!---------!---------!---------!");
  141.                 send("]>");
  142.                 portsin(temp, 41);
  143.                 send(G->CR[u]);
  144.                 if (temp[0] == 0){
  145.                     send("]Aborted...");
  146.                     send(G->CR[u]);
  147.                     return;}
  148.                     strcpy(filename,":wish:");
  149.                     strcat(filename,G->modulename[u]);
  150.                     strcat(filename,".info");
  151.                     if ((stream = fopen(filename, "a")) == NULL) { /* Open the file */
  152.                     send("]FILE ERROR cannot open %s ]", filename);
  153.                     print("\nFile ERROR Cannot Open %s W",filename);
  154.                        return;}
  155.                        gettime("%m/%d/%y",datetime); /* gets the date in m/d/y */
  156.                     if (fprintf(stream,"%-41s %-9s %-29s\r",temp,datetime,G->username[u])==EOF) print("bad fprintf conversion\n");
  157.                     fclose(stream); 
  158.                     send(G->CR[u]);
  159.                     send("Your wish has been added to the WishList!");
  160.                     print("C> Added to WishList -> ",G->username[u]);}}
  161.                         }
  162.                     }